/**
 * Created by Forcs on 16/4/14.
 */

var Pages = require('../models/Pages');

var PageController = function () {
};

PageController.prototype.savePage = function (req, res) {
  var body = req.body;
  var page = new Pages({
    code: body.code,
    name: body.name,
    product: body.product
  });
  page.save(function (err, result) {
    if (err) {
      res.json({
        code: 0,
        msg: err.toString()
      });
      return;
    }

    res.json({
      code: 1,
      msg: 'ok',
      result: result
    });
  });
};

PageController.prototype.onRouting = function (router) {
  router.post('/save', this.savePage)
};

module.exports = PageController;
